import React from 'react';
import {connect} from 'react-redux'
import {withRouter} from 'react-router-dom'

//获取reducer
@connect(
  state=>state,
  {}
)
//获取router
@withRouter
class Auth extends React.Component{
  componentDidMount() {
    //如果有用户名就跳到聊天页，如没有则跳到登陆页
    if(this.props.User.user){
      this.props.history.push('/talk')
    }else {
      this.props.history.push('/')
    }
  }

  render() {
    return null
  }
}

export default Auth
